package cn.fengliu.controller.Stu;

import cn.fengliu.Dao.*;
import cn.fengliu.entity.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.UUID;

@Controller   //创建对象，并且装配到 IOC容器
@RequestMapping("/s_stu")
public class S_StuController {
    @Autowired
    UserDao userDao;
@Autowired
    TaskDao taskDao;
@Autowired
    MarkDao markDao;
    public S_StuController() {
        System.out.println("stuController 对象被创建了");
    }
    @RequestMapping("/findCourse")
    public String findCourse(HttpSession session,Model model){
        User user = (User) session.getAttribute("user");
        if (user!=null) {
            System.out.println(user.getClz().getClzno());
            List<Task> course = taskDao.findCourse(user.getClz().getClzno());
            System.out.println(course);
            model.addAttribute("tasks", course);
        }
        return "/stu/findCourse";
}
    @RequestMapping("/findMyMark")
    public String findMyMark(HttpSession session,Model model){
        User user = (User) session.getAttribute("user");
      if (user!=null) {
          System.out.println(user.getPhone());
          List<Mark> scores = markDao.findByScore(user.getPhone());
          System.out.println(scores);
          model.addAttribute("scores", scores);
      }
        return "/stu/findMyMark";
    }

}
